package spawners {
	import actors.Actor;
	import actors.Fish;
	
	import common.FMath;
	
	import flash.events.TimerEvent;
	import flash.geom.Point;
	
	import funge.FishFunge;
	import funge.IFunge;
	
	public class FishSpawner extends GenericSpawner {
		public function FishSpawner(speed:int, total:int) {
			super(null, speed, total);
		}
		
		override protected function spawn(event:TimerEvent):void {
			var fish:Fish = new Fish(new Point(Math.random() * _tank.width, 0));

			fish.color = FMath.randColor;
			fish.crudPerception = Math.random() * 100;
			fish.fishPerception = Math.random() * 100;
			fish.sizeMax = Math.random() * 8;
			fish.accel = Math.random() * .2;
			fish.init();
			
			//Befunge
////			var programOne:Befunge = new Befunge();
//			var programTwo:Befunge = new Befunge();
////			programOne.randomize();
//			programTwo.template();
////			fish.program = programOne.blend(programTwo);
////			trace(fish.program);
//			fish.program = programTwo;
//			fish.program.actor = fish;
			
			//FishFunge
			var program:IFunge = new FishFunge();
			program.template();
			//program.randomize();
			fish.program = program;
			program.actor = fish;
//			trace(program);

			_actorMaster.addActor(fish);
		}
		
		private function randCommand(actor:Actor):String {
			var commands:Vector.<String> = actor.availableCommands;
			var index:int = Math.random() * commands.length;
			return commands[index];
		}
	}
}
